package com.gs.synedocket.control;

import android.content.Context;
import android.view.View;

public class PopupWindow extends android.widget.PopupWindow {

    public PopupWindow(Context context) {
        super(context);
    }

    @Override
    public void showAsDropDown(View anchor) {
        setHighVersion(anchor);
        super.showAsDropDown(anchor);
    }

    private void setHighVersion(View anchor) {
//        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//            Rect rect = new Rect();
//            anchor.getGlobalVisibleRect(rect);
//            DisplayMetrics outMetrics = new DisplayMetrics();
//            Context context = anchor.getContext();
//            ((Activity) context).getWindowManager().getDefaultDisplay().getRealMetrics(outMetrics);
//            int h = outMetrics.heightPixels - rect.bottom;
//            setHeight(h);
//        }
    }

    @Override
    public void showAsDropDown(View anchor, int xOff, int yOff) {
        setHighVersion(anchor);
        super.showAsDropDown(anchor, xOff, yOff);

    }

}
